<template>
  <div v-if="!!chartData.data1.data.length" class="chart-container">
    <barLine :chart-data="chartData"></barLine>
  </div>
</template>
<script>
import barLine from '../../charts/barLine.vue'
import { getShfllngk } from '@/api/socialSecurity'
export default {
  name: 'economicallyDisadvantagedElderly',
  data() {
    return {
      chartData: {
        xAxis: { name: '', data: [] },
        yAxis1: { name: '单位：亿元', data: [] },
        yAxis2: { name: '单位：人', data: [] },
        data1: { name: '发放金额', data: [], unit: '亿元' },
        data2: { name: '人数', data: [], unit: '人' }
      }
    }
  },
  components: {
    barLine
  },
  mounted() {
    this.getData()
  },
  methods: {
    async getData() {
      const res = await getShfllngk('经济困难老年人')
      res.result.forEach(item => {
        this.chartData.xAxis.data.push(item.year)
        this.chartData.data1.data.push(item.money)
        this.chartData.data2.data.push(item.person_num)
      })
    }
  }
}
</script>
<style scoped>
.chart-container {
  height: 210px;
}
</style>
